package com.example.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;

import javax.annotation.PostConstruct;

/**
 * DeFi相关配置，演示@ConfigurationProperties用法
 * @ConfigurationProperties 适合批量注入配置项，不支持SpEL表达式
 * @Value 适合单个属性注入，支持SpEL表达式
 * 对应配置前缀：app.defi
 */
@Component
@ConfigurationProperties(prefix = "app.defi")
public class DefiProperties {
    /** 手续费 */
    private Float fee;
    /** 手续费列表 */
    private List<Double> fees;
    /** 用户名列表 */
    private List<String> names;
    /** 汇率 */
    private Float ratio;
    /** 最小金额 */
    private Long minAmount;
    /** 功能开关 */
    private Boolean enabled;

    // getter/setter
    public Float getFee() { return fee; }
    public void setFee(Float fee) { this.fee = fee; }
    public List<Double> getFees() { return fees; }
    public void setFees(List<Double> fees) { this.fees = fees; }
    public List<String> getNames() { return names; }
    public void setNames(List<String> names) { this.names = names; }
    public Float getRatio() { return ratio; }
    public void setRatio(Float ratio) { this.ratio = ratio; }
    public Long getMinAmount() { return minAmount; }
    public void setMinAmount(Long minAmount) { this.minAmount = minAmount; }
    public Boolean getEnabled() { return enabled; }
    public void setEnabled(Boolean enabled) { this.enabled = enabled; }

    @PostConstruct 
    public void debugConfig() {
        System.out.println("=== DeFi 配置项 ===");
        System.out.println("DeFi功能开关: " + (enabled != null && enabled ? "已启用" : "未启用"));
        System.out.println("DeFi手续费: " + fee);
        System.out.println("DeFi手续费列表: " + fees);
        System.out.println("DeFi用户列表: " + names);
        System.out.println("DeFi汇率: " + ratio);
        System.out.println("DeFi最小金额: " + minAmount);
        System.out.println("===================");
    }
}
